Function initializers as properties#61636
Conversation
There was a problem hiding this comment.
Pull Request Overview
This PR updates the binder logic for expando initializers when they are function‐like, distinguishing between prototype properties and non‑prototype properties.
- When the expando is assigned to a prototype, only the Method flag is set; otherwise, both Method and Property flags are combined.
sandersn
left a comment
There was a problem hiding this comment.
This change needs tests. This probably changes tonnes of existing tests, so it's a matter of
$ hereby runtests-parallel$ hereby baseline-accept
and then committing the updates in tests/baselines/reference
| excludes = SymbolFlags.MethodExcludes; | ||
| } | ||
| else { | ||
| includes = SymbolFlags.Method | SymbolFlags.Property; |
There was a problem hiding this comment.
This should just be Property, I'm pretty sure. They're a function property, but don't have useful this semantics, static vs instance distinction, etc.
| @@ -3491,8 +3491,14 @@ function createBinder(): (file: SourceFile, options: CompilerOptions) => void { | |||
| let excludes = SymbolFlags.None; | |||
| // Method-like | |||
| if (isFunctionLikeDeclaration(getAssignedExpandoInitializer(declaration)!)) { | |||
There was a problem hiding this comment.
Since you don't need a custom includes you can reduce this code change down to
| if (isFunctionLikeDeclaration(getAssignedExpandoInitializer(declaration)!)) { | |
| if (isPrototypeProperty && isFunctionLikeDeclaration(getAssignedExpandoInitializer(declaration)!)) { |
and the default case at the bottom of the function will apply.
Fixes #59112